package base.ioput.StremIO;

import java.io.*;

/**
 * 字节转换成字符
 */
public class TransStreamDemo {

    public static void main(String[] args) throws IOException {
        //1，获取键盘录入对象。
        //InputStream in = System.in;

        //2，将字节流对象转成字符流对象，使用转换流。InputStreamReader
        //InputStreamReader isr = new InputStreamReader(in);

        //3，为了提高效率，将字符串进行缓冲区技术高效操作。使用BufferedReader
        //BufferedReader bufr = new BufferedReader(isr);
        


        //键盘的最常见写法。
        BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in));


//		OutputStream out = System.out;
//		OutputStreamWriter osw = new OutputStreamWriter(out);
//		BufferedWriter bufw = new BufferedWriter(osw);
        BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(System.out));


        String line = null;

        while ((line = bufr.readLine()) != null) {
            if ("over".equals(line)) break;
            bufw.write(line.toUpperCase());
            bufw.newLine();
            bufw.flush();
        }

        bufr.close();

    }



    private static void transeDemo(){

        try  {
            // 字符流 → 字节流
            FileOutputStream fos = new FileOutputStream("files\\fw.txt");
            OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
            BufferedWriter writer = new BufferedWriter(osw);
            writer.write("Hello, World!");
            writer.newLine();
            writer.write("Hello, World!000");
            writer.flush();
            writer.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }









}
